package com.whlilong.jxc.sys;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;

public class SetTableColColorListener implements Listener {
	private Table table = null;

	public SetTableColColorListener(Table table){
		this.table = table;
	}
	@Override
	public void handleEvent(Event event) {
		// TODO Auto-generated method stub
		
		if((event.detail & SWT.SELECTED) != 0){
			GC gc = event.gc;
			Rectangle area = null;
		if(table != null){
			area = table.getClientArea();
		}
		
		Rectangle rect = event.getBounds();
//		Color foreColor = new Color (Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)/*, 0x8c, 0xb3, 0xe1*/);
//		gc.setForeground(foreColor);
		gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
		gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		gc.fillGradientRectangle(0, rect.y-3, area.width, rect.height, true);
		event.detail &= ~SWT.SELECTED;
//		foreColor.dispose();
		gc.dispose();
		}
	}
	
	
	

}
